package net.lzzy.practices.entities;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 表示一个题目实体，包括题目的内容、解析、类型以及关联的选项。
 * 题目按章节分组，并且与章节之间有多对一的关系。
 */
@Entity
@Getter
@Setter
public class Question extends BaseEntity{
    @Transient
    public static final int TYPE_RADIO = 0;

    @Transient
    public static final int TYPE_JUDGE = 1;

    @Transient
    public static final int TYPE_MULTI = 2;
    private int type;

    private String content;

    private String analysis;

    private int ordinal;

    @OneToMany(cascade = CascadeType.PERSIST, mappedBy = "question")
    private List<Option> options = new ArrayList<>();

    @ManyToOne
    private Chapter chapter;

    @OneToMany(mappedBy = "question")
    private List<Result> results = new ArrayList<>();
}
